From af38c83e8c7fd94f54a315aba2562bbda8c9d8d1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Tue, 19 Nov 2013 12:15:06 +0100 Subject: [PATCH] mediawiki.hlist: Use mw.hook( 'wikipage.content' ) in JS fallback MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit …to make sure that any dynamically-inserted content will be processed as well. Change-Id: Ibc34668fea309c319118b29f51300da3ed06311a --- resources/mediawiki/mediawiki.hlist.js | 41 +++++++++++++++----------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/resources/mediawiki/mediawiki.hlist.js b/resources/mediawiki/mediawiki.hlist.js index ef981367e5..77d8fdcd57 100644 --- a/resources/mediawiki/mediawiki.hlist.js +++ b/resources/mediawiki/mediawiki.hlist.js @@ -1,24 +1,31 @@ /** - IE 8: Add pseudo-selector class to last-child list items + .hlist fallbacks for IE 6, 7 and 8. @author [[User:Edokter]] */ -jQuery( function( $ ) { - if ( $.client.profile().name === 'msie' ) { - if ( $.client.profile().versionNumber === 8 ) { - $( '.hlist' ).find( 'dd:last-child, dt:last-child, li:last-child' ) - .addClass( 'hlist-last-child' ); +( function ( mw, $ ) { + var profile = $.client.profile(); + + if ( profile.name === 'msie' ) { + if ( profile.versionNumber === 8 ) { + /* IE 8: Add pseudo-selector class to last-child list items */ + mw.hook( 'wikipage.content' ).add( function ( $content ) { + $content.find( '.hlist' ).find( 'dd:last-child, dt:last-child, li:last-child' ) + .addClass( 'hlist-last-child' ); + } ); } + else if ( profile.versionNumber <= 7 ) { /* IE 7 and below: Generate interpuncts and parentheses */ - if ( $.client.profile().versionNumber <= 7 ) { - var $hlists = $( '.hlist' ); - $hlists.find( 'dt:not(:last-child)' ) - .append( ': ' ); - $hlists.find( 'dd:not(:last-child)' ) - .append( '· ' ); - $hlists.find( 'li:not(:last-child)' ) - .append( '· ' ); - $hlists.find( 'dl dl, dl ol, dl ul, ol dl, ol ol, ol ul, ul dl, ul ol, ul ul' ) - .prepend( '( ' ).append( ') ' ); + mw.hook( 'wikipage.content' ).add( function ( $content ) { + var $hlists = $content.find( '.hlist' ); + $hlists.find( 'dt:not(:last-child)' ) + .append( ': ' ); + $hlists.find( 'dd:not(:last-child)' ) + .append( '· ' ); + $hlists.find( 'li:not(:last-child)' ) + .append( '· ' ); + $hlists.find( 'dl dl, dl ol, dl ul, ol dl, ol ol, ol ul, ul dl, ul ol, ul ul' ) + .prepend( '( ' ).append( ') ' ); + } ); } } -} ); +}( mediaWiki, jQuery ) ); -- 2.20.1